<?php
namespace Activity\Models;

class Lottery extends Base
{
    public function initialize()
    {
    }

    public function getSource()
    {
        return 'daishu_site_lottery_prize';
    }

    /**
     * @return array|bool
     */
    public function gets()
    {
        $query = 'SELECT `id`,`name`,`number`,`type` FROM `daishu_site_lottery_prize` WHERE `number`>0  ORDER BY `type` DESC';
        try {
            $ret = $this->db()->query($query)->fetchAll();
            if ($ret !== false && is_array($ret) && count($ret) > 0) {
                return $ret;
            }
        } catch (\PDOException $ex) {
            $this->errorLog('SELECT', $this->db()->getSQLStatement(), $ex->getMessage(), __FILE__, __LINE__);
        }
        return false;
    }

    public function getPrizes()
    {
        $query = 'SELECT `id` FROM `daishu_site_lottery_prize`   ORDER BY `type` DESC';
        try {
            $ret = $this->db()->query($query)->fetchAll();
            if ($ret !== false && is_array($ret) && count($ret) > 0) {
                return $ret;
            }
        } catch (\PDOException $ex) {
            $this->errorLog('SELECT', $this->db()->getSQLStatement(), $ex->getMessage(), __FILE__, __LINE__);
        }
        return false;
    }

}
